#!/bin/sh
#
# The following SunSolutions script launches httpd, waissearch, and Netscape 
# on Solaris SPARC, Solaris x86, and SunOS
# Author: Marc Sacoolas (marc.sacoolas@sun.com)
#   Date: April 4, 1995
# below is for the cgi-scripts
DISC_NAME=Sun-Solutions_CD-April-1997
# below is for everything else

disc_name="SunSolutions";disc_rest="Sun Solutions CD April 1997"
export disc_name disc_rest

# initialize variables

dir_exist=0
echo ""
echo "          $disc_rest initializing ..."
echo ""
	        			
# set CDMOUNT to path from the command line arguements

CDMOUNT=`expr \
        $0'/' : '\(/\)[^/]*//*$' \
        \| $0'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \
        \| .`
# if command line path is current directory then set CDMOUNT to pwd
# CDMOUNT cannot be set to . because other programs/scripts
# need the absolute path in CD_MOUNT
if [ "$CDMOUNT" = "." ]; then
        CDMOUNT=`pwd`
fi

CD_MOUNT=$CDMOUNT

export CD_MOUNT dir_exist

if [ -h $HOME/.netscape/lock ]; then
	echo '\07'
        echo "It looks like you are currently running Netscape Navigator."
        echo "You should quit it before running $disc_rest!"
        echo "Press <RETURN> to continue or <CTRL> C to abort..."
        read a
fi

# os type and arch

check_os()
{
        os_ver="`/bin/uname -r | /bin/grep 5\[.]`"
        export os_ver

        if [ -n "$os_ver" ]; then
# must be running Solaris 2.x
                machine_type="`/bin/uname -m`"
                os_type="`/bin/uname -r`"
                if [ "$machine_type" = "i86pc" ]; then
                        OS_TYPE=""
                        CDWARE_ENV=Solaris_x86
                else
# must be on a SPARCarchitecture-based machine
                        bcp="`/bin/pkginfo | /bin/grep SUNWbcp`"
# check for bcp and set CDWARE_ENV accordingly???
                        CDWARE_ENV=Solaris_2
                fi
        else
# must be running Solaris 1.x
                GUI=products/bin/Solaris_1/cdmanager
                GUI_BIN=cdmgr
                CDWARE_ENV=Solaris_1
        fi

#
# CDWARE_HOME used by screendemo, slidecacher, and seaudio
#
CDWARE_HOME=$CDMOUNT/products/bin/$CDWARE_ENV$OS_TYPE

export GUI CDWARE_ENV CDWARE_HOME OS_TYPE
}
# print out legal text as required by the lawyers
echo " "    
cat $CD_MOUNT/products/$disc_name/text/legal.txt

check_os
#### SUNOS PATCH INFORMATION ADDED 3/19/97 ###

#	if [ "$CDWARE_ENV" = "Solaris_1" ]; then
#	$OPENWINHOME/bin/cmdtool -Wb 250 250 210 -Wl "SunOS Patch Information" -Wx large -Ww 80 -Wh 30 -Wp 100 100 $CDMOUNT/products/bin/httpd/$CDWARE_ENV/patch.sh
#	fi
####						###


if [ "$OPENWINHOME" != "" ]; then
	OPENWINHOME="/usr/openwin"; export OPENWINHOME	
fi

export LD_LIBRARY_PATH HOTJAVA_HOME CLASSPATH PATH

LD_LIBRARY_PATH=$CD_MOUNT/products/.lib/$CDWARE_ENV/lib:/usr/openwin/lib:/usr/lib
CLASSPATH=./:$CD_MOUNT/products/bin/gui/$CDWARE_ENV:$CD_MOUNT/products/bin/gui//classes:$CD_MOUNT/products/$disc_name/classes
if [ "$CDWARE_ENV" = "Solaris_1" ]; then
PATH=/tmp/httpd/.cgi-bin:/usr/ucb:$OPENWINHOME/bin:/usr/bin:/usr/sbin:$PATH
XNLSPATH=$CD_MOUNT/products/bin/gui/$CDWARE_ENV/nls
XKEYSYMDB=$CD_MOUNT/products/bin/gui/$CDWARE_ENV
else
PATH=/tmp/httpd/.cgi-bin:/usr/bin:$OPENWINHOME/bin:/usr/sbin:$PATH
fi

# play welcome audio clip

if [ -w /dev/audio ]; then 

  if [ $CDWARE_ENV != "Solaris_1" ]; then
	audioplay -i $CD_MOUNT/products/$disc_name/sounds/welcome.au&
        PID_AUDIO=$!
  else
	cat $CD_MOUNT/products/$disc_name/sounds/welcome.au > /dev/audio&
        PID_AUDIO=$!
  fi


fi

# play welcome mpeg file

PRODUCT_DIR=$CD_MOUNT/products
export PRODUCT_DIR 

export WWW_HOME WWW_FIRST

# move only needed files and symlink for "file" URLs, if necessary

if [ ! -d /tmp/httpd ]; then
	mkdir /tmp/httpd
	mkdir /tmp/httpd/bin
	mkdir /tmp/httpd/cache
# excite read-only problem
	mkdir /tmp/httpd/collections
	chmod 777 /tmp/httpd/collections
	cp -r $CD_MOUNT/products/bin/httpd/conf /tmp/httpd
	cp -r $CD_MOUNT/products/bin/httpd/logs /tmp/httpd&
	chmod -R 777 /tmp/httpd

	ln -s $PRODUCT_DIR /tmp/httpd/.products 
fi
if [ ! -h /tmp/httpd/.excite ]; then
        ln -s $PRODUCT_DIR/bin/Excite/$CDWARE_ENV /tmp/httpd/.excite
fi

if [ "$CDWARE_ENV" != "Solaris_x86" ]; then
# get around read-only excite problem

	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.cf /tmp/httpd/collections/SunSol.cf
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.conf /tmp/httpd/collections/SunSol.conf
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.dat /tmp/httpd/collections/SunSol.dat
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.dir /tmp/httpd/collections/SunSol.dir
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.fdat /tmp/httpd/collections/SunSol.fdat
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.fidx /tmp/httpd/collections/SunSol.fidx
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.fnam /tmp/httpd/collections/SunSol.fnam
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.idf /tmp/httpd/collections/SunSol.idf
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.idx /tmp/httpd/collections/SunSol.idx
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.info /tmp/httpd/collections/SunSol.info
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.inv /tmp/httpd/collections/SunSol.inv
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.key /tmp/httpd/collections/SunSol.key
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.last /tmp/httpd/collections/SunSol.last
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.lpt /tmp/httpd/collections/SunSol.lpt
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.lst /tmp/httpd/collections/SunSol.lst
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.norm /tmp/httpd/collections/SunSol.norm
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.norm.raw /tmp/httpd/collections/SunSol.norm.raw
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.prog /tmp/httpd/collections/SunSol.prog
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.ptr /tmp/httpd/collections/SunSol.ptr
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.size /tmp/httpd/collections/SunSol.size
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.sum /tmp/httpd/collections/SunSol.sum
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.trp /tmp/httpd/collections/SunSol.trp
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.unstem /tmp/httpd/collections/SunSol.unstem
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol.ver /tmp/httpd/collections/SunSol.ver
	ln -s  /tmp/httpd/.products/bin/Excite/collections/SunSol_one.idx /tmp/httpd/collections/SunSol_one.idx

# get around read-only excite problem

        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.cf /tmp/httpd/collections/catalyst.cf
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.conf /tmp/httpd/collections/catalyst.conf
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.dat /tmp/httpd/collections/catalyst.dat
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.dir /tmp/httpd/collections/catalyst.dir
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.fdat /tmp/httpd/collections/catalyst.fdat
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.fidx /tmp/httpd/collections/catalyst.fidx
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.fnam /tmp/httpd/collections/catalyst.fnam
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.idf /tmp/httpd/collections/catalyst.idf
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.idx /tmp/httpd/collections/catalyst.idx
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.info /tmp/httpd/collections/catalyst.info
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.inv /tmp/httpd/collections/catalyst.inv
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.key /tmp/httpd/collections/catalyst.key
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.last /tmp/httpd/collections/catalyst.last
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.lpt /tmp/httpd/collections/catalyst.lpt
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.lst /tmp/httpd/collections/catalyst.lst
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.norm /tmp/httpd/collections/catalyst.norm
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.norm.raw /tmp/httpd/collections/catalyst.norm.raw
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.prog /tmp/httpd/collections/catalyst.prog
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.ptr /tmp/httpd/collections/catalyst.ptr
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.size /tmp/httpd/collections/catalyst.size
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.sum /tmp/httpd/collections/catalyst.sum
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.trp /tmp/httpd/collections/catalyst.trp
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.unstem /tmp/httpd/collections/catalyst.unstem
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst.ver /tmp/httpd/collections/catalyst.ver
        ln -s  /tmp/httpd/.products/bin/Excite/collections/catalyst_one.idx /tmp/httpd/collections/catalyst_one.idx

else
 #read-only excite problem
 
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.cf /tmp/httpd/collections/SunSol.cf
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.conf /tmp/httpd/collections/SunSol.conf
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.dat /tmp/httpd/collections/SunSol.dat
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.dir /tmp/httpd/collections/SunSol.dir
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.fdat /tmp/httpd/collections/SunSol.fdat
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.fidx /tmp/httpd/collections/SunSol.fidx
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.fnam /tmp/httpd/collections/SunSol.fnam
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.idf /tmp/httpd/collections/SunSol.idf
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.idx /tmp/httpd/collections/SunSol.idx
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.info /tmp/httpd/collections/SunSol.info
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.inv /tmp/httpd/collections/SunSol.inv
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.key /tmp/httpd/collections/SunSol.key
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.last /tmp/httpd/collections/SunSol.last
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.lpt /tmp/httpd/collections/SunSol.lpt
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.lst /tmp/httpd/collections/SunSol.lst
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.norm /tmp/httpd/collections/SunSol.norm
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.norm.raw /tmp/httpd/collections/SunSol.norm.raw
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.prog /tmp/httpd/collections/SunSol.prog
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.ptr /tmp/httpd/collections/SunSol.ptr
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.size /tmp/httpd/collections/SunSol.size
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.sum /tmp/httpd/collections/SunSol.sum
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.trp /tmp/httpd/collections/SunSol.trp
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.unstem /tmp/httpd/collections/SunSol.unstem
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol.ver /tmp/httpd/collections/SunSol.ver
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/SunSol_one.idx /tmp/httpd/collections/SunSol_one.idx
 
# get around read-only excite problem
 
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.cf /tmp/httpd/collections/catalyst.cf
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.conf /tmp/httpd/collections/catalyst.conf
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.dat /tmp/httpd/collections/catalyst.dat
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.dir /tmp/httpd/collections/catalyst.dir
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.fdat /tmp/httpd/collections/catalyst.fdat
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.fidx /tmp/httpd/collections/catalyst.fidx
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.fnam /tmp/httpd/collections/catalyst.fnam
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.idf /tmp/httpd/collections/catalyst.idf
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.idx /tmp/httpd/collections/catalyst.idx
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.info /tmp/httpd/collections/catalyst.info
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.inv /tmp/httpd/collections/catalyst.inv
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.key /tmp/httpd/collections/catalyst.key
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.last /tmp/httpd/collections/catalyst.last
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.lpt /tmp/httpd/collections/catalyst.lpt
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.lst /tmp/httpd/collections/catalyst.lst
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.norm /tmp/httpd/collections/catalyst.norm
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.norm.raw /tmp/httpd/collections/catalyst.norm.raw
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.prog /tmp/httpd/collections/catalyst.prog
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.ptr /tmp/httpd/collections/catalyst.ptr
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.size /tmp/httpd/collections/catalyst.size
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.sum /tmp/httpd/collections/catalyst.sum
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.trp /tmp/httpd/collections/catalyst.trp
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.unstem /tmp/httpd/collections/catalyst.unstem
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst.ver /tmp/httpd/collections/catalyst.ver
        ln -s  /tmp/httpd/.products/bin/Excite/Solaris_x86/collections/catalyst_one.idx /tmp/httpd/collections/catalyst_one.idx

fi
# create temp mailcap file
	key=$
	#MAILCAP=/tmp/.mailcap
	#export MAILCAP
	echo "application/x-key-sh; /bin/sh %s " > /tmp/httpd/.$disc_name
	echo "video/*; /tmp/httpd/.cgi-bin/xanim -geometry =10X10+675+210 +Ss1.25 +Av10 %s " >> /tmp/httpd/.$disc_name
	echo "application/pdf; /tmp/httpd/.cgi-bin/acroread %s " >> /tmp/httpd/.$disc_name
	# Pageview is better for postscript, but less forgiving.  Need different PS viewer.
	if [ "$CDWARE_ENV" = "Solaris_1" ]; then
	echo "application/postscript; $OPENWINHOME/bin/pageview %s " >> /tmp/httpd/.$disc_name
	else
	echo "application/postscript; $OPENWINHOME/bin/imagetool %s " >> /tmp/httpd/.$disc_name
	fi

echo $PID_AUDIO >/tmp/httpd/sound.pid

# needed srm.conf doc for httpd conf

echo ""
echo "     NCSA World Wide Web server initializing ..."		
echo ""
echo "		Portions developed at the National Center"
echo "		for Supercomputing Applications at the"
echo "		University of Illinois at Urbana-Champaign."	
echo ""	

if [ ! -h /tmp/httpd/.cgi-bin ]; then
	ln -s $PRODUCT_DIR/bin/httpd/$CDWARE_ENV /tmp/httpd/.cgi-bin
fi

# if slower machine, use non-imaged mapped page

if [ "`/bin/uname -m | sed 's/sun4//g'" = "c" -o "`/bin/uname -m | sed 's/i86//g'" = "pc" -a "$1" != "fast" -o "$1" = "slow"  ]; then
	ln -s $PRODUCT_DIR/$disc_name/index4c.html /tmp/httpd/index.html
	WWW_HOME=file:///tmp/httpd/.products/SunSolutions/index4c.html
	WWW_FIRST=http://localhost:7999/cgi-bin/killsound.pl?slow
else
	ln -s $PRODUCT_DIR/$disc_name/index4x.html /tmp/httpd/index.html
	WWW_HOME=file:///tmp/httpd/.products/SunSolutions/index4x.html
	WWW_FIRST=http://localhost:7999/cgi-bin/killsound.pl?fast
fi

echo "DocumentRoot $CD_MOUNT/products" > /tmp/httpd/conf/srm.conf
echo 'UserDir public_html' >> /tmp/httpd/conf/srm.conf
echo 'HeaderName public_html' >> /tmp/httpd/conf/srm.conf
echo 'DirectoryIndex index.html' >> /tmp/httpd/conf/srm.conf
echo 'FancyIndexing on' >> /tmp/httpd/conf/srm.conf
echo 'AddType application/x-key-sh .sh' >> /tmp/httpd/conf/srm.conf
echo 'AddType application/postscript .ps .eps .ai' >> /tmp/httpd/conf/srm.conf
echo 'AddType application/compressed .Z' >> /tmp/httpd/conf/srm.conf
echo 'AddType video/movie .mov' >> /tmp/httpd/conf/srm.conf
echo 'AddIconByType (TXT,/icons/text.xbm) text/*' >> /tmp/httpd/conf/srm.conf
echo 'AddIconByType (IMG,/icons/image.xbm) image/*' >> /tmp/httpd/conf/srm.conf
echo 'AddIconByType (SND,/icons/sound.xbm) audio/*' >> /tmp/httpd/conf/srm.conf
echo 'AddIcon /icons/movie.xbm .mpg .qt' >> /tmp/httpd/conf/srm.conf
echo 'AddIcon /icons/binary.xbm bin' >> /tmp/httpd/conf/srm.conf
echo 'AddIcon /icons/back.xbm ..' >> /tmp/httpd/conf/srm.conf
echo 'AddIcon /icons/menu.xbm ^^DIRECTORY^^' >> /tmp/httpd/conf/srm.conf
echo 'AddIcon /icons/blank.xbm ^^BLANKICON^^' >> /tmp/httpd/conf/srm.conf
echo 'DefaultIcon /icons/unknown.xbm' >> /tmp/httpd/conf/srm.conf
echo 'ReadmeName README' >> /tmp/httpd/conf/srm.conf
echo 'HeaderName HEADER' >> /tmp/httpd/conf/srm.conf
echo 'IndexIgnore */.??* *~ *# */HEADER* */README*' >> /tmp/httpd/conf/srm.conf
echo 'AccessFileName .htaccess' >> /tmp/httpd/conf/srm.conf
echo 'DefaultType text/plain' >> /tmp/httpd/conf/srm.conf
echo "ScriptAlias /.categories/ /tmp/httpd/.cgi-bin/show.bat" >> /tmp/httpd/conf/srm.conf
echo "ScriptAlias /cgi-bin/ $CD_MOUNT/products/bin/httpd/cgi-bin/" >> /tmp/httpd/conf/srm.conf
echo "ScriptAlias /JavaWorld/cgi-bin/ $CD_MOUNT/products/JavaWorld/cgi-bin/" >> /tmp/httpd/conf/srm.conf
echo "ScriptAlias /SunWorld/cgi-bin/ $CD_MOUNT/products/SunWorld/cgi-bin/" >> /tmp/httpd/conf/srm.conf
#echo "Alias /docs/ $CD_MOUNT/products/$disc_name/docs/" >> /tmp/httpd/conf/srm.conf

if [ "$CDWARE_ENV" = "Solaris_1" ]; then 
echo "Alias /catalog/SunSolutions.frame.html /tmp/httpd/.products/catalog/sunos.html" >> /tmp/httpd/conf/srm.conf
echo "Alias /catalog/index.html /tmp/httpd/.products/catalog/sunos.html" >> /tmp/httpd/conf/srm.conf
echo "Alias /index.html /tmp/httpd/.products/catalog/sunos.html" >> /tmp/httpd/conf/srm.conf
echo "Alias /catalog/index.htm /tmp/httpd/.products/catalog/sunos.html" >> /tmp/httpd/conf/srm.conf
fi 

# generate access.conf file

echo '<Directory /tmp/httpd/>' >> /tmp/httpd/conf/access.conf
echo 'Options Indexes FollowSymLinks' >> /tmp/httpd/conf/access.conf
echo '</Directory>' >> /tmp/httpd/conf/access.conf
echo "<Directory $CD_MOUNT/products/*>" >> /tmp/httpd/conf/access.conf
echo 'Options Indexes FollowSymLinks ExecCGI' >> /tmp/httpd/conf/access.conf
echo 'AllowOverride All' >> /tmp/httpd/conf/access.conf
echo '<Limit GET>' >> /tmp/httpd/conf/access.conf
echo 'order allow,deny' >> /tmp/httpd/conf/access.conf
echo 'allow from all' >> /tmp/httpd/conf/access.conf
echo '</Limit>' >> /tmp/httpd/conf/access.conf
echo '</Directory>' >> /tmp/httpd/conf/access.conf

# append ServerName to http file for disc specification

echo "ServerName $DISC_NAME" >> /tmp/httpd/conf/httpd.conf-dist

# Check to see if the user is root, if so, change to
# "-nobody" 
#

USER=`/usr/ucb/whoami`
if [ "$USER" = "root" ]; then
        echo "User nobody" >>/tmp/httpd/conf/httpd.conf-dist
        if [ "$CDWARE_ENV" = "Solaris_1" ]; then 
        echo "Group nogroup" >>/tmp/httpd/conf/httpd.conf-dist
        else
        echo "Group nobody" >>/tmp/httpd/conf/httpd.conf-dist
        fi 
fi

# launch wais search deamen

if [ "$CDWARE_ENV" = "Solaris_1" ]; then 
    
   ln -s $PRODUCT_DIR/$disc_name/waisSearch.html /tmp/httpd/search.html
   ln -s $PRODUCT_DIR/$disc_name/index4c.wais.html /tmp/httpd/index4c.html
   ln -s $PRODUCT_DIR/$disc_name/index4x.wais.html /tmp/httpd/index4x.html

	# if "/tmp/httpd/.wais" symlink is not already there, then
	# create link for wais-src and wais on CDrom


	if [ ! -h /tmp/httpd/.wais ]; then
        ln -s $PRODUCT_DIR/.wais /tmp/httpd
	fi

    echo "     Launching WAIS server ..."
    echo ""
    echo "          Copyright (c) MCNC, Clearinghouse for Networked"
    echo "          Information Discovery and Retrieval, 1993."

   /tmp/httpd/.cgi-bin/waisserver -p 7998 -d $CD_MOUNT/products/.wais/wais_SunSolutions >/tmp/httpd/waisserver.log 2>&1 &
  PID_CDROM=$!
 
  export PID_CDROM
else
   ln -s $PRODUCT_DIR/$disc_name/exciteSearch.html /tmp/httpd/search.html
   ln -s $PRODUCT_DIR/$disc_name/index4c.excite.html /tmp/httpd/index4c.html
   ln -s $PRODUCT_DIR/$disc_name/index4x.excite.html /tmp/httpd/index4x.html

 
fi 


#launch httpd

$CD_MOUNT/products/bin/httpd/cgi-bin/httpd -f /tmp/httpd/conf/httpd.conf-dist

echo ""
echo "		NOTE: If you have internet access through" 
echo "		a fire-wall, you may have to set a \"proxy\""
echo "		server under \"Network options\" in Netscape." 


if [ "$NETSCAPE_CATALYST" = "" ]; then
        PATH=$PATH:$CD_MOUNT/products/bin/gui/$CDWARE_ENV
        NETSCAPE_VERSION="`netscape -version 2>&1| /tmp/httpd/.cgi-bin/perl -n -e 's?\D*([0-9.]*).*?\1? ? print : print "none"'`"
        #NETSCAPE_VERSION="2.00"

        #POST_VERSION_201=`echo $NETSCAPE_VERSION|/tmp/httpd/.cgi-bin/perl -n -e '/2\.(\d[2-9]|[1-9]\d)/ || /[3-9]\./ ? print "post" : print "ant"'`
        POST_VERSION_300=`echo $NETSCAPE_VERSION|/tmp/httpd/.cgi-bin/perl -n -e '/3\.(\d[1-9]|[1-9]\d)/ || /[4-9]\./ ? print "post" : print "ant"'`
        #POST_VERSION_300=`echo $NETSCAPE_VERSION|/tmp/httpd/.cgi-bin/perl -n -e '/[3-9]\./ ? print "post" : print "ant"'`
        #echo "POST_VERSION_300="$POST_VERSION_300
        if [ $POST_VERSION_300 = "post" ];then
                echo
                echo "WARNING: a version of Netscape Navigator 3.00 or later has been detected in your PATH!"
                echo "Netscape Navigator "$NETSCAPE_VERSION" will be used for the Sun Solutions CD"


                echo ""
                #echo $PATH
                NETSCAPE_CATALYST=`echo $PATH|/tmp/httpd/.cgi-bin/perl -n -e '
                        @DIRS=split(/:/);
                        foreach $dir (@DIRS) {
                                if (-x "$dir/netscape" && -f _) {
                                        print "$dir/netscape\n";
                                        last;
                                }
                        }'`
        fi
fi
                export NETSCAPE_CATALYST


if [ -f $HOME/.netscape/preferences ]; then
#change
   perl -p -i.solutions -e 's?^NO_PROXY:.*$?NO_PROXY: localhost?;
                s?^PROXY_MODE:.*$?PROXY_MODE:   1?;
                s?^SHOW_DIRECTORY_BUTTONS:.*$?SHOW_DIRECTORY_BUTTONS:   False?;
                s?^SHOW_URL:.*$?SHOW_URL:       True?;
		s?^AUTOLOAD_IMAGES:.*$?AUTOLOAD_IMAGES:      True?;
                s?^PERSONAL_MIME_TYPES:.*$?PERSONAL_MIME_TYPES: /tmp/httpd/conf/mime.types?;        
                #s?^MAILCAP:.*$?MAILCAP: /tmp/httpd/.SunSolutions?;
                #s?^MIME_TYPES:.*$?MIME_TYPES:   /tmp/httpd/conf/mime.types?;
                s?^PERSONAL_MAILCAP:.*$?PERSONAL_MAILCAP:       /tmp/httpd/.SunSolutions?;        
                s?^HOME_DOCUMENT:.*$?HOME_DOCUMENT:     $ENV{"WWW_HOME"}?;
                s?^DISABLE_JAVA:.*$?DISABLE_JAVA:       False?;
		s?^SHOW_TOOLBAR:.*$?SHOW_TOOLBAR:         True?;
		s?^WARN_ENTER_SECURE:.*$?WARN_ENTER_SECURE:      False?;
		s?^WARN_LEAVE_SECURE:.*$?WARN_LEAVE_SECURE:      False?;
		s?^WARN_MIXED_SECURE:.*$?WARN_MIXED_SECURE:      False?;
		s?^WARN_SUBMIT_INSECURE:.*$?WARN_SUBMIT_INSECURE:   False?;
		s?^SHOW_URL:.*$?SHOW_URL:             True?;
		s?^SHOW_DIRECTORY_BUTTONS:.*$?SHOW_DIRECTORY_BUTTONS:  False?;
		s?^FTP_FILE_INFO:.*$?FTP_FILE_INFO:        True?;
		s?^SHOW_SECURITY_BAR:.*$?SHOW_SECURITY_BAR    True?;
                s?^FONT_SPEC:[  ]*([^-]*)-([^-]*)-([^-]*)-(.*)$?FONT_SPEC: \1-\2-140-\4?;
   ' $HOME/.netscape/preferences

  dir_exist=1
else
  cp -r $CD_MOUNT/products/bin/gui/.netscape $HOME
  dir_exist=0
fi


echo ""
echo "$disc_rest is starting ..."
echo ""
echo "Please note the following:" 
echo "--------------------------" 
echo "- To run many of the slide shows there must be at least 5 megabytes" 
echo "  of available disk space in /tmp.  Please verify the available disk" 
echo "  space in /tmp before running the slide shows." 
echo " " 
echo " " 

# cleanup previous line, if any
if [ -f $HOME/.mailcap ]; then
perl -nei 'print unless $_ =~ "application/x-spam-sh; /bin/sh %s"' $HOME/.mailcap > /tmp/httpd/.mailcap; cp /tmp/httpd/.mailcap $HOME/.mailcap
fi 
$CD_MOUNT/products/bin/finish.sh &
sleep 60 
exit 0
